function [output] = FUN_plotFSA(fig, t, data)
%FUN_plotFSA Summary of this function goes here
%   Detailed explanation goes here

size = length(data);
sampletime = 0.01                               %sample time that unit is second
t = 0:sampletime:(size-1) * sampletime;     %time point

time = t';
data = data';
size = length(data);
[fit_fourier2,gof,out_fourier2] = fit(time,data,'fourier2');
figure(fig);subplot(2,2,1);
plot(fit_fourier2,time,data);
title('Fourier Seriers Fitting Analysis'); axis auto %axis([0 100 0 10^6]);
xlabel('Time/s'); ylabel('Amplitude/Value');
legend( 'Data', 'fourier2')

figure(fig);subplot(2,2,3);
plot(time,out_fourier2.residuals);
title('Fitting Shift Remove Data'); axis auto %axis([0 100 0 10^6]);
xlabel('Time/s'); ylabel('Amplitude/Value');
legend('RemovedData')

w = fit_fourier2.w;
freqByFourier2 = 2*pi/w

[fit_fourier8,gof,out_fourier8] = fit(time,data,'fourier8');
figure(fig);subplot(2,2,2);
plot(fit_fourier8,time,data);
title('Fourier Seriers Fitting Analysis'); axis auto %axis([0 100 0 10^6]);
xlabel('Time/s'); ylabel('Amplitude/Value');
legend( 'Data', 'fourier8');

figure(fig);subplot(2,2,4);
plot(time,out_fourier8.residuals);
title('Fitting Shift Remove Data'); axis auto %axis([0 100 0 10^6]);
xlabel('Time/s'); ylabel('Amplitude/Value');
legend('RemovedData')

w = fit_fourier8.w;
freqByFourier8 = 2*pi/w
output = out_fourier8;
end
